From 48af68894052101f52ed8390efb61ad9cfd8b47b Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Sun, 22 Apr 2018 21:42:03 +0800 Subject: [PATCH] build: Use cc.links to check linker arguments Instead of hard-coding linker flags for a specific operating system and a specific compiler, we can should cc.links to test them, so they can be used on more operating systems and compilers. --- meson.build | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index cdd83e7635..895cef9fc0 100644 --- a/meson.build +++ b/meson.build @@ -284,8 +284,12 @@ endif common_ldflags = [] -if host_machine.system() == 'linux' and cc.get_id() == 'gcc' - common_ldflags += [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ] +if os_unix and not os_darwin + foreach ldflag: [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ] + if cc.links('int main () { return 0; }', name: ldflag, args: ldflag) + common_ldflags += [ ldflag ] + endif + endforeach endif # Maintain compatibility with autotools -- 2.30.2